#!/bin/bash

pres=data/washington.pdf

pdftk "$pres" burst output web/images/%4.4d.pdf

pages=$(cat doc_data.txt|grep NumberOfPages|sed "s/NumberOfPages: //")

rm -f doc_data.txt

echo $pages

#
# Creo il file di manifest
#

outfile="web/images/manifest.js"

echo "var _images = [ " > $outfile
n=1
while (( $n <= $pages ))
do
	fname=$(printf "%4.4d" $n)
	#echo "	{ \"img\" : \"$fname.pdf\", \"width\" : 2048, \"height\" : 1152 }, " >> $outfile
	echo "	{ \"img\" : \"$fname.jpg\", \"width\" : 2048, \"height\" : 1152 }, " >> $outfile
	let n=$n+1
done

echo "];" >> $outfile

#
# Immagini jpg per i test
#

n=0
while (( $n < $pages ))
do
	echo $n

	let v=$n+1
	fname=$(printf "%4.4d" $v)

	convert -density 150 "$pres"[$n] -resize 2048x web/images/$fname.jpg

	let n=$n+1
done



